home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1996 / MacHack 1996.toast / Presentations / Presentations ’91 / MPW Stand-Alone Libraries / UMultiSegSA.p < prev    next >
Text File  |  1991-02-26  |  4KB  |  137 lines

  1. {[a-,body+,h-,o=100,r+,rec+,t=4,u+,#+,j=20/57/1$,n+]}
  2. {$D+}
  3.  
  4. UNIT UMultiSegSA;
  5.  
  6. INTERFACE
  7.  
  8. {--------------------------------------------------------------------------------------------------}
  9.  
  10. USES
  11.     { • MacApp }
  12.     UMacApp,
  13.  
  14.     { • Building Blocks }
  15.  
  16.     { • Required for this unit's interface }
  17.     UAssociation,
  18.  
  19.     { • Implementation use }
  20.     CursorCtl, Signal, PasLibIntf, IntEnv, ErrMgr, Events, OSUtils, Memory,
  21.     Resources, Fonts, Packages, ToolUtils, Errors,
  22.  
  23.     { • Inherits from }
  24.     UMPWTool, UMakeSAGlobals, UMakeSA;
  25.  
  26. CONST
  27.     kCtorDtorSeg        = '%_Static_Constructor_Destructor_Pointers';
  28.     
  29.     kBSRSize = 4;            { size of BRA instruction }
  30.     kSegTypeSize = 4;        { size of segment type info }
  31.     kNumJTSize = 4;            { size of numJTEntries }
  32.     kCode0Hdr = 16;            { size of header at beginning of code 0 }
  33.     kCodeHdr = 4;            { size of any code segment header }
  34.     kJTEntrySize = 8;        { size of a jump table entry }
  35.                             { Start of the jump table; past the numJTEntries longword }
  36.     kJTStart = kBSRSize + kSegTypeSize + kNumJTSize;
  37.     kJTDivisor = 2;            { normal jump table has 8 byte entries, our's is 4 bytes }
  38.         
  39.     kBSRCode = $6100;        { CPU instruction for BSR $xxxxxxxx }
  40.             
  41. TYPE
  42.  
  43.     TMultiSegSA        = OBJECT (TObject)
  44.         fSrcRefNum:        Integer;
  45.         fDestRefNum:    Integer;
  46.         fJTSize:        LongInt;
  47.         fCtorJTSize:    LongInt;
  48.         fDtorJTSize:    LongInt;
  49.         fSegTabSize:    LongInt;
  50.         fSACodeSize:    LongInt;
  51.         fFileSpec:        FileSpec;
  52.         fMainType:        ResType;
  53.         fMainID:        Integer;
  54.         fMainName:        StringHandle;
  55.         fOtherType:        ResType;
  56.  
  57.         PROCEDURE TMultiSegSA.IMultiSegSA(aFile: FileSpec;
  58.                                         mainType: ResType;
  59.                                         mainID: Integer;
  60.                                         mainName: StringHandle;
  61.                                         otherType: ResType);
  62.         PROCEDURE TMultiSegSA.OpenFiles;
  63.         PROCEDURE TMultiSegSA.CloseSourceFile;
  64.         PROCEDURE TMultiSegSA.CloseDestinationFile;
  65.         PROCEDURE TMultiSegSA.ShowNumericalProgress(aStr: Str255;
  66.                                         aLong: LongInt);
  67.         PROCEDURE TMultiSegSA.ShowTextProgress(aStr: Str255);
  68.  
  69.         FUNCTION TMultiSegSA.WillBeMerged(theID: Integer;
  70.                                         theName: Str255): BOOLEAN;
  71.         PROCEDURE TMultiSegSA.CalcJTSize(rawJTSize: LongInt);
  72.         PROCEDURE TMultiSegSA.CalcCtorJTSize(theSize: LongInt);
  73.         PROCEDURE TMultiSegSA.CalcDtorJTSize(theSize: LongInt);
  74.         PROCEDURE TMultiSegSA.CalcSegTableSize(theCount: Integer;
  75.                                         hasCtorDtorJT: Boolean);
  76.         PROCEDURE TMultiSegSA.CalcSACodeSize;
  77.         
  78.         FUNCTION TMultiSegSA.GetNumJTEntries: LongInt;
  79.         FUNCTION TMultiSegSA.GetNumCtorJTEntries: LongInt;
  80.         FUNCTION TMultiSegSA.GetNumDtorJTEntries: LongInt;
  81.         FUNCTION TMultiSegSA.GetNumSegTableEntries: LongInt;
  82.  
  83.         FUNCTION TMultiSegSA.GetJTSize: LongInt;
  84.         FUNCTION TMultiSegSA.GetCtorJTSize: LongInt;
  85.         FUNCTION TMultiSegSA.GetDtorJTSize: LongInt;
  86.         FUNCTION TMultiSegSA.GetSegTableSize: LongInt;
  87.         FUNCTION TMultiSegSA.GetSACodeSize: LongInt;
  88.  
  89.         FUNCTION TMultiSegSA.GetCode0: Handle;
  90.         FUNCTION TMultiSegSA.GetCtorDtorJT: Handle;
  91.         
  92.         FUNCTION TMultiSegSA.AllocateSACode(theSize: LongInt): Handle;
  93.         
  94.         PROCEDURE TMultiSegSA.BuildBSR(code0, saCode: Handle;
  95.                                         VAR saPos: LongInt);
  96.         PROCEDURE TMultiSegSA.BuildSegType(segType: ResType;
  97.                                         saCode: Handle;
  98.                                         VAR saPos: LongInt);
  99.         PROCEDURE TMultiSegSA.BuildJumpTable(code0, saCode: Handle;
  100.                                         VAR saPos: LongInt);
  101.         PROCEDURE TMultiSegSA.BuildCtorJTable(theJT, saCode: Handle;
  102.                                         VAR saPos: LongInt);
  103.         PROCEDURE TMultiSegSA.BuildDtorJTable(theJT, saCode: Handle;
  104.                                         VAR saPos: LongInt);
  105.         PROCEDURE TMultiSegSA.BuildSegTable(saCode: Handle;
  106.                                         VAR saPos: LongInt);
  107.  
  108.         PROCEDURE TMultiSegSA.Merge1Segment(segNum: Integer;
  109.                                         theCode: Handle;
  110.                                         codeSize: LongInt;
  111.                                         saCode: Handle;
  112.                                         VAR saPos: LongInt);
  113.  
  114.         PROCEDURE TMultiSegSA.MergeCodeSegments(saCode: Handle;
  115.                                         VAR saPos: LongInt);
  116.  
  117.         PROCEDURE TMultiSegSA.AdjustMainJTable(saCode: Handle;
  118.                                         segOffset:    LongInt;
  119.                                         oldSegNum, newSegNum, jtOffset, numEntries: Integer);
  120.  
  121.         PROCEDURE TMultiSegSA.BuildStandAlone;
  122.         PROCEDURE TMultiSegSA.ReplaceSegment(theRsrc: Handle;
  123.                                         theType: ResType;
  124.                                         theID: Integer;
  125.                                         VAR theName: Str255);
  126.         PROCEDURE TMultiSegSA.AddMainSegment(VAR saCode: Handle);
  127.         PROCEDURE TMultiSegSA.AddOtherCodeSegments(saCode: Handle;
  128.                                         otherSegType: ResType);
  129.         
  130.         PROCEDURE TMultiSegSA.DoIt;
  131.     END;
  132.     
  133. {--------------------------------------------------------------------------------------------------}
  134.  
  135. IMPLEMENTATION
  136.     {$I UMultiSegSA.incl.p}
  137. END.